﻿using System;
using System.Collections.Generic;

namespace University
{
    class Student
    {
        private static HashSet<int> UsedFacultyNumbers = new HashSet<int>();

        private const int MinFacultyNumber = 10000;
        private const int MaxFacultyNumber = 99999;

        public string Name { get; private set; }
        public int FacultyNumber { get; private set; }

        public Student(string name, int facNum)
        {
            if(name == null)
            {
                throw new ArgumentNullException("Student name can not be null.");
            }
            if(name == "")
            {
                throw new ArgumentOutOfRangeException("Student name can not be empty.");
            }
            if(facNum < MinFacultyNumber || facNum > MaxFacultyNumber)
            {
                string errorMessage = string.Format("Faculty number should be between {0} and {1}.", MinFacultyNumber, MaxFacultyNumber);
                throw new ArgumentOutOfRangeException(errorMessage);
            }
            if(UsedFacultyNumbers.Contains(facNum))
            {
                string errorMessage = string.Format("FacultyNumber number {0} is already in use.", facNum);
                throw new ArgumentOutOfRangeException(errorMessage);
            }

            this.Name = name;
            this.FacultyNumber = facNum;
            UsedFacultyNumbers.Add(facNum);
        }
    }
}
